// -*- C++ -*-
-// $Id: advdlg.cpp,v 1.1 2009/07/05 21:14:56 robertl Exp $
+// $Id: advdlg.cpp,v 1.2 2009/08/28 17:08:55 robertl Exp $
//------------------------------------------------------------------------
//
// Copyright (C) 2009 S. Khai Mong <khai@mangrai.com>.
#include "advdlg.h"
//------------------------------------------------------------------------
-AdvDlg::AdvDlg(QWidget* parent,
- bool &synthShortNames,
+AdvDlg::AdvDlg(QWidget* parent,
+ bool &synthShortNames,
bool &forceGPSTypes,
bool &enableCharSetXform,
bool &previewGmap,
// -*- C++ -*-
-// $Id: dpencode.cpp,v 1.1 2009/07/05 21:14:56 robertl Exp $
+// $Id: dpencode.cpp,v 1.2 2009/08/28 17:08:55 robertl Exp $
//------------------------------------------------------------------------
//
// Original in JavaScript:
{
if (verySmall <=0.0)
verySmall = 1.0E-5;
- for(int i = 0; i < numLevels; i++)
+ for(int i = 0; i < numLevels; i++)
zoomLevelBreaks.push_back(verySmall*pow(zoomFactor, numLevels-i-1));
}
return (x>0.0) ? int(x+0.5) : int(x-0.5);
}
//------------------------------------------------------------------------
-void PolylineEncoder::createEncodings(string &encoded_points,
- const vector <LatLng> &points,
+void PolylineEncoder::createEncodings(string &encoded_points,
+ const vector <LatLng> &points,
const vector <double> dists)
{
encoded_points = "";;
}
//------------------------------------------------------------------------
-// This computes the appropriate zoom level of a point in terms of it's
+// This computes the appropriate zoom level of a point in terms of it's
// distance from the relevant segment in the DP algorithm. Could be done
// in terms of a logarithm, but this approach makes it a bit easier to
// ensure that the level is not too large.
createEncodings(encPts, points, dists);
encodeLevels(encLevels, points, dists);
}
-
-
-
-
-
-
// -*- C++ -*-
-// $Id: filterdata.cpp,v 1.2 2009/07/31 18:32:32 robertl Exp $
+// $Id: filterdata.cpp,v 1.3 2009/08/28 17:08:55 robertl Exp $
//------------------------------------------------------------------------
//
// Copyright (C) 2009 S. Khai Mong <khai@mangrai.com>.
if (merge) s += ",merge";
if (split && (pack || merge)) {
s += ",split";
- if (splitTime > 0)
+ if (splitTime > 0)
s += QString("=%1%2").arg(splitTime).arg("mhd"[splitTimeUnit]);
}
if (splitDist > 0) {
if (move) s += QString(",move=%1d%2h%3m%4s").arg(days).arg(hours).arg(mins).arg(secs);
if (title) s += QString(",title=%1").arg(titleString);
- if (s.length())
+ if (s.length())
args << "-x" << "track" + s;
return args;
}
return args;
}
-
-
// -*- C++ -*-
-// $Id: filterdlg.cpp,v 1.1 2009/07/05 21:14:56 robertl Exp $
+// $Id: filterdlg.cpp,v 1.2 2009/08/28 17:08:55 robertl Exp $
//------------------------------------------------------------------------
//
// Copyright (C) 2009 S. Khai Mong <khai@mangrai.com>.
connect(ui.helpButton, SIGNAL(clicked()), this, SLOT(helpX()));
connect(ui.resetButton, SIGNAL(clicked()), this, SLOT(resetX()));
-
+
ui.buttonBox->button(QDialogButtonBox::Ok)->setIcon(QIcon(":images/ok"));
ui.buttonBox->button(QDialogButtonBox::Cancel)->setIcon(QIcon(":images/cancel"));
//------------------------------------------------------------------------
-void FilterDialog::addFilterPage(const QString &name, FilterWidget *fw, bool*use)
+void FilterDialog::addFilterPage(const QString &name, FilterWidget *fw, bool*use)
{
QListWidgetItem *it = new QListWidgetItem(name);
it->setCheckState(*use? Qt::Checked:Qt::Unchecked);
pages[i]->setWidgetValues();
pages[i]->setEnabled(*(usePages[i]));
pages[i]->checkChecks();
- ui.filterList->item(i)->setCheckState(*(usePages[i]) ? Qt::Checked: Qt::Unchecked);
+ ui.filterList->item(i)->setCheckState(*(usePages[i]) ? Qt::Checked: Qt::Unchecked);
}
}
}
// -*- C++ -*-
-// $Id: filterwidgets.cpp,v 1.2 2009/07/31 18:32:32 robertl Exp $
+// $Id: filterwidgets.cpp,v 1.3 2009/08/28 17:08:55 robertl Exp $
//------------------------------------------------------------------------
//
// Copyright (C) 2009 S. Khai Mong <khai@mangrai.com>.
// Checkbox interlocks
addCheckEnabler(ui.titleCheck, ui.titleText);
- addCheckEnabler(ui.moveCheck,
- (QList<QWidget *> ()
+ addCheckEnabler(ui.moveCheck,
+ (QList<QWidget *> ()
<< ui.daysLabel << ui.daysSpin
<< ui.hoursLabel<< ui.hoursSpin
<< ui.minsLabel << ui.minsSpin
addCheckEnabler(ui.startCheck, ui.startEdit);
addCheckEnabler(ui.stopCheck, ui.stopEdit);
addCheckEnabler(ui.GPSFixesCheck, ui.GPSFixesCombo);
-
+
connect(ui.mergeCheck, SIGNAL(clicked()) , this, SLOT(mergeCheckX()));
connect(ui.splitCheck, SIGNAL(clicked()) , this, SLOT(OtherCheckX()));
connect(ui.packCheck, SIGNAL(clicked()), this, SLOT(packCheckX()));
ui.startEdit->setDisplayFormat("dd MMM yyyy hh:mm:ss AP");
ui.stopEdit->setDisplayFormat("dd MMM yyyy hh:mm:ss AP");
-
+
// Collect the data fields.
fopts << new BoolFilterOption(tfd.title, ui.titleCheck);
fopts << new BoolFilterOption(tfd.move, ui.moveCheck);
bool bb = ui.packCheck->isChecked() &&ui.splitCheck->isChecked();
ui.splitTimeSpin->setEnabled(bb);
ui.splitTimeCombo->setEnabled(bb);
- //ui.splitDistSpin->setEnabled(bb);
+ //ui.splitDistSpin->setEnabled(bb);
//ui.splitDistCombo->setEnabled(bb);
}
// -*- c++ -*-
-// $Id: formatload.cpp,v 1.1 2009/07/05 21:14:56 robertl Exp $
+// $Id: formatload.cpp,v 1.2 2009/08/28 17:08:55 robertl Exp $
//------------------------------------------------------------------------
//
// Copyright (C) 2009 S. Khai Mong <khai@mangrai.com>.
bool FormatLoad::skipToValidLine()
{
QRegExp regex("^(file|serial)");
- while (currentLine <lines.size() && regex.indexIn(lines[currentLine]) != 0)
+ while (currentLine <lines.size() && regex.indexIn(lines[currentLine]) != 0)
currentLine++;
return (currentLine<lines.size());
}
type = FormatOption::OPTstring;
else if (optionType == "integer") {
type = (optionMax != "" && optionMin != "") ? FormatOption::OPTboundedInt : FormatOption::OPTint;
- if (optionMax == "")
+ if (optionMax == "")
optionMax = "2147483647";
- if (optionMin == "")
+ if (optionMin == "")
optionMin = "-2147483647";
}
else if (optionType == "float") {
type = FormatOption::OPTfloat;
- if (optionMax == "")
+ if (optionMax == "")
optionMax = "1.0E308";
- if (optionMin == "")
+ if (optionMin == "")
optionMin = "-1.0E308";
}
else if (optionType == "file") {
}
QList <FormatOption> optionList2 = optionList;
- format = Format(hfields[2], xlt(hfields[4]),
+ format = Format(hfields[2], xlt(hfields[4]),
hfields[1][0] == QChar('r'), hfields[1][2] == QChar('r'), hfields[1][4] == QChar('r'),
hfields[1][1] == QChar('w'), hfields[1][3] == QChar('w'), hfields[1][5] == QChar('w'),
hfields[0] == "file",
hfields[0] == "serial",
QStringList() << hfields[3],
- optionList,
+ optionList,
optionList2);
return true;
}
bool FormatLoad::getFormats(QList<Format> &formatList)
{
formatList.clear();
-
+
QProcess babel;
babel.start("gpsbabel", QStringList() << "-^3");
if (!babel.waitForStarted())
babel.closeWriteChannel();
if (!babel.waitForFinished())
return false;
- if (babel.exitCode() != 0)
+ if (babel.exitCode() != 0)
return false;
QTextStream tstream(babel.readAll());
Format format;
if (!processFormat(format)) {
QMessageBox::information
- (0, appName,
+ (0, appName,
QObject::tr("Error processing formats from running process \"gpsbabel -^3\" at line %1").arg(lineList[currentLine]));
- }
+ }
else {
formatList << format;
}
}
return true;
}
-
// -*- C++ -*-
-// $Id: gmapdlg.cpp,v 1.1 2009/07/05 21:14:56 robertl Exp $
+// $Id: gmapdlg.cpp,v 1.2 2009/08/28 17:08:55 robertl Exp $
//------------------------------------------------------------------------
//
// Copyright (C) 2009 S. Khai Mong <khai@mangrai.com>.
class TreeAction: public QAction
{
public:
- TreeAction(const QString &text,
+ TreeAction(const QString &text,
QObject *obj, const char *member, QObject *parent): QAction(text, parent)
{
connect(this, SIGNAL(triggered()), obj, member);
}
};
//------------------------------------------------------------------------
-QString GMapDialog::formatLength(double l)
+QString GMapDialog::formatLength(double l)
{
double metricLength = l;
QString metricUnit = tr("meters");
metricUnit = "km";
metricPrecision = 3;
}
-
+
double fpsLength = l*1000.0/25.4/12.0;
QString fpsUnit = tr("feet");
int fpsPrecision = 1;
.arg(metricUnit)
.arg(fpsLength, 0, 'f', fpsPrecision)
.arg(fpsUnit));
-
+
}
//------------------------------------------------------------------------
void GMapDialog::appendWaypointInfo(QStandardItem *it, const GpxWaypoint &wpt)
it->appendRow(new StandardItem(tr("Desc: %1").arg(wpt.getDescription())));
if (wpt.getComment() != QString() && wpt.getComment() != wpt.getDescription())
it->appendRow(new StandardItem(tr("Cmt: %1").arg(wpt.getComment())));
- if (wpt.getElevation() > -50000)
+ if (wpt.getElevation() > -50000)
it->appendRow(new StandardItem(tr("Ele: %1").arg(wpt.getElevation())));
}
it->appendRow(new StandardItem(tr("Points: %1").arg(count)));
it->appendRow(new StandardItem(formatLength(trk.length())));
-
+
}
//------------------------------------------------------------------------
lay->addWidget(mapWidget);
model = new QStandardItemModel(this);
-
+
wptItem = new StandardItem(tr("Waypoints"));
wptItem->setCheckable(true);
wptItem->setCheckState(Qt::Checked);
connect(mapWidget, SIGNAL(waypointClicked(int)), this, SLOT(waypointClickedX(int)));
connect(mapWidget, SIGNAL(routeClicked(int)), this, SLOT(routeClickedX(int)));
connect(mapWidget, SIGNAL(trackClicked(int)), this, SLOT(trackClickedX(int)));
- connect(ui.treeView, SIGNAL(doubleClicked(const QModelIndex &)),
+ connect(ui.treeView, SIGNAL(doubleClicked(const QModelIndex &)),
this, SLOT(treeDoubleClicked(const QModelIndex&)));
connect(ui.treeView->selectionModel(), SIGNAL(selectionChanged (const QItemSelection &, const QItemSelection &)),
this, SLOT(selectionChangedX(const QItemSelection &, const QItemSelection &)));
}
//-------------------------------------------------------------------------
-void GMapDialog::itemChangedX(QStandardItem *it)
+void GMapDialog::itemChangedX(QStandardItem *it)
{
bool show = (it->checkState() == Qt::Checked);
if (it == trkItem) {
- if (show)
+ if (show)
mapWidget->showTracks(gpx.getTracks());
- else
+ else
mapWidget->hideAllTracks();
}
else if (it == wptItem) {
if (show)
mapWidget->showWaypoints(gpx.getWaypoints());
- else
+ else
mapWidget->hideAllWaypoints();
}
else if (it == rteItem) {
if (show)
mapWidget->showRoutes(gpx.getRoutes());
- else
+ else
mapWidget->hideAllRoutes();
}
}
}
}
-}
+}
//-------------------------------------------------------------------------
int GMapDialog::waypointIndex(QStandardItem *it)
{
for (int j=0; j<wptList.size(); j++){
- if (it == wptList[j])
+ if (it == wptList[j])
return j;
}
return -1;
int GMapDialog::trackIndex(QStandardItem *it)
{
for (int j=0; j<trkList.size(); j++){
- if (it == trkList[j])
+ if (it == trkList[j])
return j;
}
return -1;
int GMapDialog::routeIndex(QStandardItem *it)
{
for (int j=0; j<rteList.size(); j++){
- if (it == rteList[j])
+ if (it == rteList[j])
return j;
}
return -1;
}
//-------------------------------------------------------------------------
-void GMapDialog::treeDoubleClicked(const QModelIndex &idx)
+void GMapDialog::treeDoubleClicked(const QModelIndex &idx)
{
QStandardItem *it = model->itemFromIndex(idx);
int i = waypointIndex(it);
}
//-------------------------------------------------------------------------
-void GMapDialog::waypointClickedX(int i)
+void GMapDialog::waypointClickedX(int i)
{
if (i>=0 && i < wptList.size()) {
QStandardItem *it = wptList[i];
}
}
//-------------------------------------------------------------------------
-void GMapDialog::trackClickedX(int i)
+void GMapDialog::trackClickedX(int i)
{
if (i>=0 && i <trkList.size()) {
QStandardItem *it = trkList[i];
}
//-------------------------------------------------------------------------
-void GMapDialog::routeClickedX(int i)
+void GMapDialog::routeClickedX(int i)
{
if (i>=0 && i <rteList.size()) {
QStandardItem *it = rteList[i];
int k=0;
foreach (QStandardItem*w, wptList) {
QModelIndex idx = model->indexFromItem(w);
- if (desel.contains(idx))
+ if (desel.contains(idx))
mapWidget->setWaypointColorBlue(k);
- if (sel.contains(idx))
+ if (sel.contains(idx))
mapWidget->setWaypointColorRed(k);
k++;
}
}
//------------------------------------------------------------------------
-void GMapDialog::expandCollapseAll(const QList<QStandardItem *> &li,
+void GMapDialog::expandCollapseAll(const QList<QStandardItem *> &li,
QStandardItem *top, bool exp)
{
ui.treeView->setExpanded(model->indexFromItem(top), exp);
}
//------------------------------------------------------------------------
-void GMapDialog::checkUncheckAll(const QList<QStandardItem *> &li,
+void GMapDialog::checkUncheckAll(const QList<QStandardItem *> &li,
QStandardItem *top, bool ck)
{
top->setCheckState(ck ? Qt::Checked: Qt::Unchecked);
//------------------------------------------------------------------------
void GMapDialog::showAllWaypoints()
{
- foreach (GpxWaypoint wpt, gpx.getWaypoints())
+ foreach (GpxWaypoint wpt, gpx.getWaypoints())
wpt.setVisible(true);
checkUncheckAll(wptList, wptItem, true);
mapWidget->showWaypoints(gpx.getWaypoints());
//------------------------------------------------------------------------
void GMapDialog::showAllTracks()
{
- foreach (GpxTrack trk, gpx.getTracks())
+ foreach (GpxTrack trk, gpx.getTracks())
trk.setVisible(true);
checkUncheckAll(trkList, trkItem, true);
mapWidget->showTracks(gpx.getTracks());
//------------------------------------------------------------------------
void GMapDialog::showAllRoutes()
{
- foreach (GpxRoute rte, gpx.getRoutes())
+ foreach (GpxRoute rte, gpx.getRoutes())
rte.setVisible(true);
checkUncheckAll(rteList, rteItem, true);
mapWidget->showRoutes(gpx.getRoutes());
//------------------------------------------------------------------------
void GMapDialog::hideAllWaypoints()
{
- foreach (GpxWaypoint wpt, gpx.getWaypoints())
+ foreach (GpxWaypoint wpt, gpx.getWaypoints())
wpt.setVisible(false);
checkUncheckAll(wptList, wptItem, false);
mapWidget->showWaypoints(gpx.getWaypoints());
//------------------------------------------------------------------------
void GMapDialog::hideAllTracks()
{
- foreach (GpxTrack trk, gpx.getTracks())
+ foreach (GpxTrack trk, gpx.getTracks())
trk.setVisible(false);
checkUncheckAll(trkList, trkItem, false);
mapWidget->showTracks(gpx.getTracks());
//------------------------------------------------------------------------
void GMapDialog::hideAllRoutes()
{
- foreach (GpxRoute rte, gpx.getRoutes())
+ foreach (GpxRoute rte, gpx.getRoutes())
rte.setVisible(false);
checkUncheckAll(rteList, rteItem, false);
mapWidget->showRoutes(gpx.getRoutes());
}
//------------------------------------------------------------------------
-void GMapDialog::showContextMenu(const QPoint &pt)
+void GMapDialog::showContextMenu(const QPoint &pt)
{
QModelIndex idx = ui.treeView->indexAt(pt);
QStandardItem *it = model->itemFromIndex(idx);
else {
}
}
-
// -*- C++ -*-
-// $Id: gpx.cpp,v 1.1 2009/07/05 21:14:56 robertl Exp $
+// $Id: gpx.cpp,v 1.2 2009/08/28 17:08:55 robertl Exp $
//------------------------------------------------------------------------
//
// Copyright (C) 2009 S. Khai Mong <khai@mangrai.com>.
#include "gpx.h"
-static QDateTime decodeDateTime(const QString s)
+static QDateTime decodeDateTime(const QString s)
{
QDateTime utc = QDateTime::fromString(s, "yyyy-MM-dd'T'HH:mm:ss'Z'");
return utc;
return count <=2 ;
}
-class GpxHandler: public QXmlDefaultHandler
+class GpxHandler: public QXmlDefaultHandler
{
-public:
- GpxHandler(): QXmlDefaultHandler()
+public:
+ GpxHandler(): QXmlDefaultHandler()
{
state = e_noop;
}
- else if (state == e_wpt ||
+ else if (state == e_wpt ||
state == e_trkpt || state == e_trkseg || state == e_trk ||
state == e_rte || state == e_rtept) {
}
else {
- //fprintf(stderr, "localName: %s name: %s\n",
+ //fprintf(stderr, "localName: %s name: %s\n",
//localName.toStdString().c_str(), qName.toStdString().c_str());
}
return true;
else if (localName == "trk") {
state = stateStack.takeLast();
- if (!trackIsEmpty(currentTrk))
+ if (!trackIsEmpty(currentTrk))
trkList << currentTrk;
}
}
else {
- //fprintf(stderr, "end ---- localName: %s name: %s\n\n",
+ //fprintf(stderr, "end ---- localName: %s name: %s\n\n",
//localName.toStdString().c_str(), qName.toStdString().c_str());
}
return true;
bool Gpx::read(const QString & fileName)
{
QFile file(fileName);
- if (!file.open(QIODevice::ReadOnly))
+ if (!file.open(QIODevice::ReadOnly))
return false;
QXmlInputSource xmlIn(&file);
routes = gpxHandler.rteList;
return true;
}
- else
+ else
return false;
}
-
-
// -*- C++ -*-
-// $Id: help.cpp,v 1.3 2009/07/27 04:04:42 robertl Exp $
+// $Id: help.cpp,v 1.4 2009/08/28 17:08:55 robertl Exp $
//------------------------------------------------------------------------
//
// Copyright (C) 2009 S. Khai Mong <khai@mangrai.com>.
//------------------------------------------------------------------------
void ShowHelp(const char *name)
{
- QUrl urlname("file://" + QApplication::applicationDirPath() +
+ QUrl urlname("file://" + QApplication::applicationDirPath() +
"/help/" + name);
// FIXME(robertl): This shoud probably parent from QApplication::mainWidget();
QWebView *view = new QWebView();
view->load(urlname);
view->show();
}
-
// -*- C++ -*-
-// $Id: latlng.cpp,v 1.1 2009/07/05 21:14:56 robertl Exp $
+// $Id: latlng.cpp,v 1.2 2009/08/28 17:08:55 robertl Exp $
//------------------------------------------------------------------------
//
// Copyright (C) 2009 S. Khai Mong <khai@mangrai.com>.
*
* @sa http://en.wikipedia.org/wiki/Law_of_haversines
*/
-static double ArcInRadians(const LatLng& from, const LatLng& to)
+static double ArcInRadians(const LatLng& from, const LatLng& to)
{
double latitudeArc = (from.lat() - to.lat()) * DEG_TO_RAD;
double longitudeArc = (from.lng() - to.lng()) * DEG_TO_RAD;
// -*- C++ -*-
-// $Id: main.cpp,v 1.3 2009/07/23 03:22:24 robertl Exp $
+// $Id: main.cpp,v 1.4 2009/08/28 17:08:55 robertl Exp $
//------------------------------------------------------------------------
//
// Copyright (C) 2009 S. Khai Mong <khai@mangrai.com>.
installTranslation(app, "qt_");
installTranslation(app, "gpsbabelfe_");
installTranslation(app, "gpsbabel_");
-
+
QCoreApplication::setOrganizationName("GPSBabel");
QCoreApplication::setOrganizationDomain("gpsbabel.org");
QCoreApplication::setApplicationName("GPSBabelFE");
mainWindow.show();
app->exec();
}
-
// -*- C++ -*-
-// $Id: mainwindow.cpp,v 1.4 2009/08/06 03:19:10 robertl Exp $
+// $Id: mainwindow.cpp,v 1.5 2009/08/28 17:08:55 robertl Exp $
//------------------------------------------------------------------------
//
// Copyright (C) 2009 S. Khai Mong <khai@mangrai.com>.
}
//------------------------------------------------------------------------
-static QString MakeOptions(const QList<FormatOption>& options)
+static QString MakeOptions(const QList<FormatOption>& options)
{
QString str;
for (int i=0; i<options.size(); i++) {
}
//------------------------------------------------------------------------
-static QString MakeOptionsNoLeadingComma(const QList<FormatOption>& options)
+static QString MakeOptionsNoLeadingComma(const QList<FormatOption>& options)
{
QString str = MakeOptions(options);
return (str.length()) ? str.mid(1) : str;
-
+
}
//------------------------------------------------------------------------
MainWindow::MainWindow(QWidget* parent): QMainWindow(parent)
lights[1] = QPixmap::fromImage(QImage(":images/01.png").scaledToHeight(20, Qt::SmoothTransformation));
lights[2] = QPixmap::fromImage(QImage(":images/10.png").scaledToHeight(20, Qt::SmoothTransformation));
lights[3] = QPixmap::fromImage(QImage(":images/11.png").scaledToHeight(20, Qt::SmoothTransformation));
-
+
ui.outputWindow->setReadOnly(true);
}
//------------------------------------------------------------------------
-void MainWindow::inputDeviceOptBtnClicked()
+void MainWindow::inputDeviceOptBtnClicked()
{
fmtChgInterlock = true;
QString fmt = bd.inputDeviceFormat;
ui.outputFormatCombo->addItem(formatList[k].getDescription(), QVariant(k));
}
setComboToFormat(ui.outputFormatCombo, fmt, true);
- }
+ }
else {
ui.outputStackedWidget->setCurrentWidget(ui.outputFilePage);
ui.outputFilePage->setEnabled(false);
if (!finfo.isDir() && (!filterForFormatIncludes(idx, finfo.suffix()))) {
startFile = finfo.dir().absolutePath();
}
-
- QStringList userList =
+
+ QStringList userList =
QFileDialog::getOpenFileNames(0, tr("Select one or more input files"),
- startFile,
+ startFile,
filterForFormat(idx));
if (userList.size()) {
bd.inputBrowse = userList[0];
bd.inputFileNames = userList;
QString str;
for (int i=0; i<bd.inputFileNames.size(); i++) {
- if (i != 0)
+ if (i != 0)
str += ", ";
str += "\"" + bd.inputFileNames[i] + "\"";
}
if (!finfo.isDir() && (!filterForFormatIncludes(idx, finfo.suffix()))) {
startFile = finfo.dir().absolutePath();
}
-
+
QString str =
QFileDialog::getSaveFileName(0, tr("Output File Name"),
- startFile,
+ startFile,
filterForFormat(idx));
if (str.length() != 0) {
bd.outputBrowse = str;
{
QList<int>indices;
for (int i=0; i<formatList.size(); i++) {
- if (formatList[i].isReadSomething() && formatList[i].isFileFormat())
+ if (formatList[i].isReadSomething() && formatList[i].isFileFormat())
indices<<i;
}
return indices;
{
QList<int>indices;
for (int i=0; i<formatList.size(); i++) {
- if (formatList[i].isReadSomething() && formatList[i].isDeviceFormat())
+ if (formatList[i].isReadSomething() && formatList[i].isDeviceFormat())
indices<<i;
}
return indices;
{
QList<int>indices;
for (int i=0; i<formatList.size(); i++) {
- if (formatList[i].isWriteSomething() && formatList[i].isFileFormat())
+ if (formatList[i].isWriteSomething() && formatList[i].isFileFormat())
indices<<i;
}
return indices;
{
QList<int>indices;
for (int i=0; i<formatList.size(); i++) {
- if (formatList[i].isWriteSomething() && formatList[i].isDeviceFormat())
+ if (formatList[i].isWriteSomething() && formatList[i].isDeviceFormat())
indices<<i;
}
return indices;
void MainWindow::loadFormats()
{
if (!FormatLoad().getFormats(formatList)) {
- QMessageBox::information(0, QString(appName),
+ QMessageBox::information(0, QString(appName),
tr("Error reading format configuration. "
"Check that the backend program \"gpsbabel\" is properly installed "
"and is in the current PATH\n\n"
inputDeviceFormatIndices().size() == 0 ||
outputFileFormatIndices().size() == 0 ||
outputDeviceFormatIndices().size() == 0) {
- QMessageBox::information(0, QString(appName),
+ QMessageBox::information(0, QString(appName),
tr("Some file/device formats were not found during initialization. "
"Check that the backend program \"gpsbabel\" is properly installed "
"and is in the current PATH\n\n"
}
//------------------------------------------------------------------------
-void MainWindow::setIndicatorLights(QLabel *label, const QString type, int code)
+void MainWindow::setIndicatorLights(QLabel *label, const QString type, int code)
{
label->setPixmap(lights[code]);
QString s;
- switch (code)
+ switch (code)
{
default:
case 0:
}
Format ifmt = formatList[currentComboFormatIndex(ui.inputFormatCombo)];
Format ofmt = formatList[currentComboFormatIndex(ui.outputFormatCombo)];
-
+
ui.xlateWayPtsCk->setEnabled(ifmt.isReadWaypoints() && ofmt.isWriteWaypoints());
ui.xlateTracksCk->setEnabled(ifmt.isReadTracks() && ofmt.isWriteTracks());
ui.xlateRoutesCk->setEnabled(ifmt.isReadRoutes() && ofmt.isWriteRoutes());
-
+
setIndicatorLights(ui.wayPtLabel, tr("waypoints"), iconIndex(ifmt.isReadWaypoints(), ofmt.isWriteWaypoints()));
setIndicatorLights(ui.trackLabel, tr("tracks"), iconIndex(ifmt.isReadTracks(), ofmt.isWriteTracks()));
setIndicatorLights(ui.routeLabel, tr("routes"), iconIndex(ifmt.isReadRoutes(), ofmt.isWriteRoutes()));
}
//------------------------------------------------------------------------
-void MainWindow::displayOptionsText(QLineEdit *le, QComboBox *combo, bool isInput)
+void MainWindow::displayOptionsText(QLineEdit *le, QComboBox *combo, bool isInput)
{
int fidx = combo->itemData(combo->currentIndex()).toInt();
if (isInput)
le->setText(MakeOptionsNoLeadingComma(formatList[fidx].getInputOptions()));
- else
+ else
le->setText(MakeOptionsNoLeadingComma(formatList[fidx].getOutputOptions()));
}
}
//------------------------------------------------------------------------
-void MainWindow::inputFormatChanged(int comboIdx)
+void MainWindow::inputFormatChanged(int comboIdx)
{
if (fmtChgInterlock)
return;
}
//------------------------------------------------------------------------
-void MainWindow::outputFormatChanged(int comboIdx)
+void MainWindow::outputFormatChanged(int comboIdx)
{
if (fmtChgInterlock)
return;
}
//------------------------------------------------------------------------
-void MainWindow::inputOptionButtonClicked()
+void MainWindow::inputOptionButtonClicked()
{
int fidx = currentComboFormatIndex(ui.inputFormatCombo);
- OptionsDlg optionDlg(0,
+ OptionsDlg optionDlg(0,
formatList[fidx].getName(),
formatList[fidx].getInputOptionsRef());
optionDlg.setWindowTitle(QString(appName) + " - " + tr("Options for %1").arg(formatList[fidx].getName()));
}
//------------------------------------------------------------------------
-void MainWindow::outputOptionButtonClicked()
+void MainWindow::outputOptionButtonClicked()
{
int fidx = currentComboFormatIndex(ui.outputFormatCombo);
OptionsDlg optionDlg(0, formatList[fidx].getName(), formatList[fidx].getOutputOptionsRef());
QMessageBox::information(0, QString(appName), tr("No valid waypoints/routes/tracks translation specified"));
return false;
}
-
+
if ((bd.inputType == BabelData::fileType) &&
(bd.inputFileNames.size() == 0)) {
QMessageBox::information(0, QString(appName), tr("No input file specified"));
QMessageBox::information(0, QString(appName), tr("No valid output specified"));
return false;
}
- else if (bd.outputType == BabelData::fileType &&
+ else if (bd.outputType == BabelData::fileType &&
bd.outputFileName.length() == 0) {
QMessageBox::information(0, QString(appName), tr("No output file specified"));
return false;
}
//------------------------------------------------------------------------
-bool MainWindow::runGpsbabel(const QStringList &args, QString &errorString,
+bool MainWindow::runGpsbabel(const QStringList &args, QString &errorString,
QString &outputString)
{
QProcess *proc = new QProcess(0);
errorString = QString(tr("Process \"%1\" did not start")).arg(name);
return false;
}
-
+
waitDlg->show();
waitDlg->exec();
int exitCode = -1;
if (exitCode == 0)
retStatus = true;
else {
- errorString =
+ errorString =
QString(tr("Process exited unsucessfully with code %1"))
.arg(exitCode);
retStatus = false;
}
}
//------------------------------------------------------------------------
-void MainWindow::applyActionX()
+void MainWindow::applyActionX()
{
getWidgetValues();
if (!isOkToGo())
if (bd.synthShortNames) args << "-s";
// Input char set if specified
- if (bd.enableCharSetXform && bd.inputCharSet != QString())
+ if (bd.enableCharSetXform && bd.inputCharSet != QString())
args << "-c" << bd.inputCharSet;
if (bd.xlateWayPts) args << "-w";
bd.inputFileFormat : bd.inputDeviceFormat);
args << "-i";
args << (formatList[fidx].getName() + MakeOptions(formatList[fidx].getInputOptions()));
-
+
// Input file(s) or device
if (bd.inputType == BabelData::fileType) {
- for (int i=0; i<bd.inputFileNames.size(); i++)
+ for (int i=0; i<bd.inputFileNames.size(); i++)
args << "-f" << bd.inputFileNames[i];
}
else {
args << filterData.getAllFilterStrings();
// Output char set if specified
- if (bd.enableCharSetXform && bd.outputCharSet != QString())
+ if (bd.enableCharSetXform && bd.outputCharSet != QString())
args << "-c" << bd.outputCharSet;
// Output type, with options
bd.outputFileFormat : bd.outputDeviceFormat));
args << "-o";
args << (formatList[fidx].getName() + MakeOptions(formatList[fidx].getOutputOptions()));
-
+
// output file or device option
if (outIsFile) {
if (bd.outputFileName != "")
this->show();
}
}
- else
+ else
ui.outputWindow->appendPlainText(tr("Error running gpsbabel: %1\n").arg(errorString));
}
//------------------------------------------------------------------------
-void MainWindow::closeActionX()
+void MainWindow::closeActionX()
{
QDateTime wt= upgrade->getUpgradeWarningTime();
if (wt.isValid()) {
}
//------------------------------------------------------------------------
-void MainWindow::closeEvent(QCloseEvent*)
+void MainWindow::closeEvent(QCloseEvent*)
{
closeActionX();
}
QSettings settings;
bd.saveSettings(settings);
- for (int i=0; i<formatList.size(); i++)
+ for (int i=0; i<formatList.size(); i++)
formatList[i].saveSettings(settings);
for (int i=0; i<filterData.filters.size(); i++)
filterData.filters[i]->saveSettings(settings);
{
QSettings settings;
bd.restoreSettings(settings);
- for (int i=0; i<formatList.size(); i++)
+ for (int i=0; i<formatList.size(); i++)
formatList[i].restoreSettings(settings);
for (int i=0; i<filterData.filters.size(); i++)
tr("Are you sure you want to reset all format options to default values?"),
QMessageBox::Yes | QMessageBox::No);
if (ret == QMessageBox::Yes) {
- for (int i=0; i<formatList.size(); i++)
+ for (int i=0; i<formatList.size(); i++)
formatList[i].setToDefault();
displayOptionsText(ui.inputOptionsText, ui.inputFormatCombo, true);
displayOptionsText(ui.outputOptionsText, ui.outputFormatCombo, false);
//------------------------------------------------------------------------
void MainWindow::moreOptionButtonClicked()
{
- AdvDlg advDlg(0, bd.synthShortNames,
+ AdvDlg advDlg(0, bd.synthShortNames,
bd.forceGPSTypes, bd.enableCharSetXform, bd.previewGmap, bd.debugLevel);
connect(advDlg.formatButton(), SIGNAL(clicked()),
this, SLOT(resetFormatDefaults()));
{
bool filterActive = filterData.getAllFilterStrings().size();
ui.filterStatus->setEnabled(filterActive);
- if (filterActive)
+ if (filterActive)
ui.filterStatus->setToolTip(tr("One or more data filters are active"));
else {
ui.filterStatus->setToolTip(tr("No data filters are active"));
bd.xlateTracks = ui.xlateTracksCk->isChecked();
bd.xlateRoutes = ui.xlateRoutesCk->isChecked();
}
-
-
// -*- C++ -*-
-// $Id: mainwindow.h,v 1.3 2009/08/06 03:19:10 robertl Exp $
+// $Id: mainwindow.h,v 1.4 2009/08/28 17:08:55 robertl Exp $
//------------------------------------------------------------------------
//
// Copyright (C) 2009 S. Khai Mong <khai@mangrai.com>.
class MainWindow: public QMainWindow {
Q_OBJECT
-
+
public:
MainWindow(QWidget* parent);
~MainWindow();
// -*- C++ -*-
-// $Id: map.cpp,v 1.1 2009/07/05 21:14:56 robertl Exp $
+// $Id: map.cpp,v 1.2 2009/08/28 17:08:55 robertl Exp $
//------------------------------------------------------------------------
//
// Copyright (C) 2009 S. Khai Mong <khai@mangrai.com>.
}
//------------------------------------------------------------------------
-Map::Map(QWidget *parent,
+Map::Map(QWidget *parent,
const Gpx &gpx, QPlainTextEdit *te):
- QWebView(parent),
+ QWebView(parent),
gpx(gpx),
mapPresent(false),
- busyCursor(false),
+ busyCursor(false),
te(te)
{
busyCursor = true;
manager = new QNetworkAccessManager(this);
connect(this,SIGNAL(loadFinished(bool)),
this,SLOT(loadFinishedX(bool)));
- this->logTimeX("Start map constuctor");
+ this->logTimeX("Start map constuctor");
QString baseFile = QApplication::applicationDirPath() + "/gmapbase.html";
if (!QFile(baseFile).exists()) {
QMessageBox::critical(0, appName,
//------------------------------------------------------------------------
void Map::loadFinishedX(bool f)
{
- this->logTimeX("Done initial page load");
- if (!f)
+ this->logTimeX("Done initial page load");
+ if (!f)
QMessageBox::critical(0, appName,
tr("Failed to load Google maps base page"));
else {
// It is appreciably faster to do the encoding on the C++ side.
int numLevels = 18;
double zoomFactor = 2;
- PolylineEncoder encoder(numLevels, zoomFactor, 0.00001);
+ PolylineEncoder encoder(numLevels, zoomFactor, 0.00001);
this->logTimeX("Start defining JS string");
;
mapPresent = true;
-
+
// Waypoints.
int num=0;
foreach (const GpxWaypoint &pt, gpx.getWaypoints() ) {
- scriptStr
+ scriptStr
<< QString("waypts[%1] = new GMarker(new GLatLng(%2), "
"{title:\"%3\",icon:blueIcon});")
.arg(num)
string encPts, encLevels;
encoder.dpEncode(encPts, encLevels, epts);
- scriptStr
+ scriptStr
<< QString("var startPt = new GLatLng(%1);").arg(fmtLatLng(epts[0]))
<< QString("var endPt = new GLatLng(%1);").arg(fmtLatLng(epts[epts.size()-1]))
<< QString("var idx = %1;").arg(num)
scriptStr
<< "for( var i=0; i<trks.length; ++i ) {"
- << " var trkbound = trks[i].getBounds();"
+ << " var trkbound = trks[i].getBounds();"
<< " bounds.extend(trkbound.getSouthWest());"
<< " bounds.extend(trkbound.getNorthEast());"
<< "}"
}
string encPts, encLevels;
encoder.dpEncode(encPts, encLevels, epts);
- scriptStr
+ scriptStr
<< QString("var startPt = new GLatLng(%1);").arg(fmtLatLng(epts[0]))
<< QString("var endPt = new GLatLng(%1);").arg(fmtLatLng(epts[epts.size()-1]))
<< QString("var idx = %1;").arg(num)
scriptStr
<< "for( var i=0; i<rtes.length; ++i ) {"
- << " var rtebound = rtes[i].getBounds();"
+ << " var rtebound = rtes[i].getBounds();"
<< " bounds.extend(rtebound.getSouthWest());"
<< " bounds.extend(rtebound.getNorthEast());"
<< "}"
<< "map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));"
<< "mclicker.logTime(\"done setCenter\");"
;
-
+
this->logTimeX("Done defining JS string");
evaluateJS(scriptStr);
this->logTimeX("Done JS evaluation");
//------------------------------------------------------------------------
void Map::markerClicked(int t, int i){
- if (t == 0)
+ if (t == 0)
emit waypointClicked(i);
- else if (t == 1)
+ else if (t == 1)
emit trackClicked(i);
- else if (t == 2)
+ else if (t == 2)
emit routeClicked(i);
}
{
QString x = show?"show": "hide";
QStringList scriptStr;
- scriptStr
+ scriptStr
<< QString("trks[%1].%2();").arg(i).arg(x)
;
evaluateJS(scriptStr);
{
QString x = show?"show": "hide";
QStringList scriptStr;
- scriptStr
+ scriptStr
<< QString("rtes[%1].%2();").arg(i).arg(x)
;
evaluateJS(scriptStr);
void Map::resizeEvent ( QResizeEvent * ev)
{
QWebView::resizeEvent(ev);
- if (mapPresent)
+ if (mapPresent)
evaluateJS(QString("map.checkResize();"));
}
//------------------------------------------------------------------------
-void Map::evaluateJS(const QString &s, bool upd)
+void Map::evaluateJS(const QString &s, bool upd)
{
this->page()->mainFrame()->evaluateJavaScript(s);
if (upd) {
}
//------------------------------------------------------------------------
-void Map::evaluateJS(const QStringList &s, bool upd)
+void Map::evaluateJS(const QStringList &s, bool upd)
{
evaluateJS(s.join("\n"), upd);
}
// -*- C++ -*-
-// $Id: optionsdlg.cpp,v 1.1 2009/07/05 21:14:56 robertl Exp $
+// $Id: optionsdlg.cpp,v 1.2 2009/08/28 17:08:55 robertl Exp $
//------------------------------------------------------------------------
//
// Copyright (C) 2009 S. Khai Mong <khai@mangrai.com>.
}
//------------------------------------------------------------------------
-FileDlgManager::FileDlgManager(QObject*parent,
+FileDlgManager::FileDlgManager(QObject*parent,
QLineEdit *le,
QToolButton *tb, bool isInFile):
QObject(parent), le(le), tb(tb), isInFile(isInFile)
{
connect(tb, SIGNAL(clicked()), this, SLOT(buttonClicked()));
}
-
+
//------------------------------------------------------------------------
QVariant getOptionValue(QList<FormatOption> opts, int k) {
- if (opts[k].getValue().toString() != "")
+ if (opts[k].getValue().toString() != "")
return opts[k].getValue();
- else
+ else
return opts[k].getDefaultValue();
}
QString str;
if (isInFile) {
str = QFileDialog::getOpenFileName(0, tr("Select input file"),
- le->text(),
+ le->text(),
"All Files (*.*)");
}
else {
str = QFileDialog::getSaveFileName(0, tr("Select output file"),
- le->text(),
+ le->text(),
"All Files (*.*)");
}
if (str != "")
QSpacerItem *horizontalSpacer = new QSpacerItem(0, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout->addItem(horizontalSpacer);
-
+
QWidget *w = 0;
- switch (options[k].getType())
+ switch (options[k].getType())
{
- case FormatOption::OPTstring:
+ case FormatOption::OPTstring:
{
QLineEdit *lineEdit = new QLineEdit(this);
SetSizeStuff(lineEdit);
}
break;
- case FormatOption::OPTinFile:
- case FormatOption::OPToutFile:
+ case FormatOption::OPTinFile:
+ case FormatOption::OPToutFile:
{
bool inFile = options[k].getType() == FormatOption::OPTinFile;
QLineEdit *lineEdit = new QLineEdit(this);
}
break;
- case FormatOption::OPTbool:
+ case FormatOption::OPTbool:
w = 0;
break;
}
checkBoxes.push_back(checkBox);
fields.push_back(w);
-
+
verticalLayout->addLayout(horizontalLayout);
}
QPushButton *helpButton = new QPushButton(this);
value = qMax(qMin(value, options[k].getMaxValue().toDouble()),options[k].getMinValue().toDouble());
options[k].setValue(QVariant(value));
}
- else
+ else
options[k].setValue(static_cast<QLineEdit*>(fields[k])->text());
}
}
// -*- c++ -*-
-// $Id: processwait.cpp,v 1.2 2009/07/20 02:30:02 robertl Exp $
+// $Id: processwait.cpp,v 1.3 2009/08/28 17:08:55 robertl Exp $
//------------------------------------------------------------------------
//
// Copyright (C) 2009 S. Khai Mong <khai@mangrai.com>.
//------------------------------------------------------------------------
-QString ProcessWaitDialog::processErrorString( QProcess::ProcessError err)
+QString ProcessWaitDialog::processErrorString( QProcess::ProcessError err)
{
switch (err)
{
- case QProcess::FailedToStart:
- return QString(tr("Process failed to start"));
+ case QProcess::FailedToStart:
+ return QString(tr("Process failed to start"));
break;
- case QProcess::Crashed:
+ case QProcess::Crashed:
return QString(tr("Process crashed"));
break;
case QProcess::Timedout:
return QString(tr("Process timedout"));
break;
case QProcess::WriteError:
- return QString(tr("Error while trying to write to process"));
+ return QString(tr("Error while trying to write to process"));
break;
case QProcess::ReadError:
return QString(tr("Error while trying to read from process"));
break;
case QProcess::UnknownError:
default:
- return QString(tr("Unknown process error"));
+ return QString(tr("Unknown process error"));
}
return QString("");
}
this->resize(400, 220);
this->setWindowTitle(QString(appName) + tr(" ... Process GPSBabel"));
QVBoxLayout *layout = new QVBoxLayout(this);
-
+
textEdit = new QPlainTextEdit(this);
textEdit->setReadOnly(true);
layout->addWidget(textEdit);
-
+
progressBar = new QProgressBar(this);
progressBar->setTextVisible(false);
layout->addWidget(progressBar);
-
+
buttonBox = new QDialogButtonBox(this);
buttonBox->setOrientation(Qt::Horizontal);
buttonBox->setStandardButtons(QDialogButtonBox::Abort);
QPushButton* btn = buttonBox->button(QDialogButtonBox::Abort);
btn->setText(tr("Stop Process"));
layout->addWidget(buttonBox);
-
- connect(process, SIGNAL(error(QProcess::ProcessError)),
+
+ connect(process, SIGNAL(error(QProcess::ProcessError)),
this, SLOT (errorX(QProcess::ProcessError)));
connect(process, SIGNAL(finished(int, QProcess::ExitStatus)),
this, SLOT (finishedX(int, QProcess::ExitStatus)));
bufferedOut = "";
//
- for (int i=0; i<=100; i+=2)
+ for (int i=0; i<=100; i+=2)
progressVals.push_back(i);
- for (int i=98; i>0; i-=2)
+ for (int i=98; i>0; i-=2)
progressVals.push_back(i);
progressIndex = progressVals.size()/2;
{
};
//------------------------------------------------------------------------
-bool ProcessWaitDialog::getExitedNormally()
+bool ProcessWaitDialog::getExitedNormally()
{
return (errorString.length() == 0);
};
//------------------------------------------------------------------------
-QString ProcessWaitDialog::getErrorString()
+QString ProcessWaitDialog::getErrorString()
{
return errorString;
};
//------------------------------------------------------------------------
-int ProcessWaitDialog::getExitCode()
+int ProcessWaitDialog::getExitCode()
{
return ecode;
};
//------------------------------------------------------------------------
-void ProcessWaitDialog::stopClickedX()
+void ProcessWaitDialog::stopClickedX()
{
process->terminate();
};
//------------------------------------------------------------------------
-void ProcessWaitDialog::timeoutX()
+void ProcessWaitDialog::timeoutX()
{
progressIndex++;
int idx = progressIndex % progressVals.size();
};
//------------------------------------------------------------------------
-void ProcessWaitDialog::finishedX(int exitCode, QProcess::ExitStatus es)
+void ProcessWaitDialog::finishedX(int exitCode, QProcess::ExitStatus es)
{
ecode = exitCode;
if (es == QProcess::CrashExit)
// appendPlainText automatically puts in a new line with every call. That's
// why you have to buffer it, and only append when we get a real newline.
//
-void ProcessWaitDialog::appendToText(const char *ptr)
+void ProcessWaitDialog::appendToText(const char *ptr)
{
outputString += QString(ptr);
for (const char *cptr = ptr; *cptr; cptr++) {
//------------------------------------------------------------------------
-void ProcessWaitDialog::readyReadStandardErrorX()
+void ProcessWaitDialog::readyReadStandardErrorX()
{
QByteArray d = process->readAllStandardError();
appendToText(d.data());
// releasing the iterator when iteration is complete.
static kern_return_t FindModems(io_iterator_t *matchingServices)
{
- kern_return_t kernResult;
+ kern_return_t kernResult;
CFMutableDictionaryRef classesToMatch;
/*! @function IOServiceMatching
undefined. If the dictionary is a fixed-capacity dictionary and
it is full before this operation, and the key does not exist in
the dictionary, the behavior is undefined.
- @param key The key of the value to set into the dictionary. If a key
+ @param key The key of the value to set into the dictionary. If a key
which matches this key is already present in the dictionary, only
the value is changed ("add if absent, replace if present"). If
no key matches the given key, the key-value pair is added to the
// CFDictionarySetValue(classesToMatch,
// CFSTR(kIOSerialBSDTypeKey),
// CFSTR(kIOSerialBSDModemType));
-
+
// Each serial device object has a property with key
// kIOSerialBSDTypeKey and a value that is one of kIOSerialBSDAllTypes,
// kIOSerialBSDModemType, or kIOSerialBSDRS232Type. You can experiment with the
// matching by changing the last parameter in the above call to CFDictionarySetValue.
-
+
// As shipped, this sample is only interested in modems,
- // so add this property to the CFDictionary we're matching on.
+ // so add this property to the CFDictionary we're matching on.
// This will find devices that advertise themselves as modems,
// such as built-in and USB modems. However, this match won't find serial modems.
}
-
+
/*! @function IOServiceGetMatchingServices
@abstract Look up registered IOService objects that match a matching dictionary.
@discussion This is the preferred method of finding IOService objects currently registered by IOKit. IOServiceAddNotification can also supply this information and install a notification of new IOServices. The matching information used in the matching dictionary may vary depending on the class of service being looked up.
@param existing An iterator handle is returned on success, and should be released by the caller when the iteration is finished.
@result A kern_return_t error code. */
- kernResult = IOServiceGetMatchingServices(kIOMasterPortDefault, classesToMatch, matchingServices);
+ kernResult = IOServiceGetMatchingServices(kIOMasterPortDefault, classesToMatch, matchingServices);
if (KERN_SUCCESS != kernResult)
{
printf("IOServiceGetMatchingServices returned %d\n", kernResult);
goto exit;
}
-
+
exit:
return kernResult;
}
-
+
// Given an iterator across a set of modems, return the BSD path to the first one.
// If no modems are found the path name is set to an empty string.
static kern_return_t GetModemPath(io_iterator_t serialPortIterator, char *bsdPath, CFIndex maxPathSize, QComboBox *box)
io_object_t modemService;
kern_return_t kernResult = KERN_FAILURE;
Boolean modemFound = false;
-
+
// Initialize the returned path
*bsdPath = '\0';
-
+
// Iterate across all modems found. In this example, we bail after finding the first modem.
-
+
while ((modemService = IOIteratorNext(serialPortIterator)) && !modemFound)
{
CFTypeRef bsdPathAsCFString;
if (bsdPathAsCFString)
{
Boolean result;
-
+
// Convert the path from a CFString to a C (NUL-terminated) string for use
// with the POSIX open() call.
-
+
result = CFStringGetCString((const __CFString*) bsdPathAsCFString,
bsdPath,
- maxPathSize,
+ maxPathSize,
kCFStringEncodingUTF8);
CFRelease(bsdPathAsCFString);
-
+
if (result) {
box->addItem(bsdPath);
}
// (void) IOObjectRelease(modemService);
}
-
+
return kernResult;
}
kernResult = FindModems(&serialPortIterator);
kernResult = GetModemPath(serialPortIterator, bsdPath, sizeof(bsdPath), box);
-}
+}
// -*- C++ -*-
-// $Id: upgrade.cpp,v 1.9 2009/08/10 21:21:29 robertl Exp $
+// $Id: upgrade.cpp,v 1.10 2009/08/28 17:08:55 robertl Exp $
/*
Copyright (C) 2009 Robert Lipe, robertlipe@gpsbabel.org
information.setDefaultButton(QMessageBox::Yes);
information.setText(response);
- information.setInformativeText(tr("Do you wish do download an upgrade?"));
+ information.setInformativeText(tr("Do you wish to download an upgrade?"));
information.setDetailedText(upgradeText);
switch (information.exec()) {